package cn.lxh.controller.app;

import cn.lxh.pojo.dto.*;
import cn.lxh.result.JSONResult;
import cn.lxh.service.IOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


@Tag(name = "订单表",description = "订单表")
@RestController
@RequestMapping("/app/order")
public class AppOrderController {

    @Autowired
    public IOrderService orderService;

    @Operation( summary= "呼叫代驾, 保存Order",description = "呼叫代驾, 保存Order")
    @Parameter(name = "orderDto",description = "订单参数",required = true)
    @PostMapping("/callDriver")
    public JSONResult callDriver(@RequestBody @Valid OrderDto orderDto){
        return JSONResult.success(orderService.callDriver(orderDto));
    }

    @Operation( summary= "司机拉取订单",description = "司机拉取订单")
    @GetMapping("/driverPullOrders")
    public JSONResult driverPullOrders(){
        return JSONResult.success(orderService.driverPullOrders());
    }

    @Operation( summary= "超时未接单, 系统自动取消",description = "超时未接单, 系统自动取消")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @PostMapping("/autoCancelOrder/{orderNo}")
    public JSONResult autoCancelOrder(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.autoCancelOrder(orderNo));
    }

    @Operation( summary= "乘客取消订单",description = "乘客取消订单")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @PostMapping("/customerCancelOrder/{orderNo}")
    public JSONResult customerCancelOrder(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.customerCancelOrder(orderNo));
    }

    @Operation( summary= "司机接单",description = "司机接单")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @PostMapping("/driverTakesOrder/{orderNo}")
    public JSONResult driverTakesOrder(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.driverTakesOrder(orderNo));
    }

    @Operation( summary= "拉取司机正在进行的订单",description = "拉取司机正在进行的订单")
    @GetMapping("/pullOngoingOrders")
    public JSONResult pullOngoingOrders(){
        return JSONResult.success(orderService.pullOngoingOrders());
    }

    @Operation( summary= "获取订单位置",description = "获取订单位置")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @GetMapping("/getOrderLocation/{orderNo}")
    public JSONResult getOrderLocation(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.getOrderLocation(orderNo));
    }

    @Operation( summary= "加载乘客进行的订单",description = "加载乘客进行的订单")
    @GetMapping("/loadOrdersInProgress")
    public JSONResult loadOrdersInProgress(){
        return JSONResult.success(orderService.loadOrdersInProgress());
    }

    @Operation( summary= "拉取司机位置",description = "拉取司机位置")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @GetMapping("/pullDriverLocation/{orderNo}")
    public JSONResult pullDriverLocation(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.pullDriverLocation(orderNo));
    }

    @Operation( summary= "司机到达代驾点",description = "司机到达代驾点")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @PostMapping("/driverArrives/{orderNo}")
    public JSONResult driverArrives(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.driverArrives(orderNo));
    }

    @Operation( summary= "司机开始代驾",description = "司机开始代驾")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @PostMapping("/driverStartDriving/{orderNo}")
    public JSONResult driverStartDriving(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.driverStartDriving(orderNo));
    }

    @Operation( summary= "司机结束代驾",description = "司机结束代驾")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @PostMapping("/driverEndDriving/{orderNo}")
    public JSONResult driverEndDriving(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.driverEndDriving(orderNo));
    }

    @Operation( summary= "司机确认费用",description = "司机确认费用")
    @Parameter(name = "orderConfirmDto",description = "其他费用参数",required = true)
    @PostMapping("/confirm")
    public JSONResult confirm(@RequestBody  @Valid OrderConfirmDto orderConfirmDto){
        return JSONResult.success(orderService.confirm(orderConfirmDto));
    }

    @Operation( summary= "加载司机账单信息",description = "加载司机账单信息")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @GetMapping("/driverOrderBill/{orderNo}")
    public JSONResult driverOrderBill(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.driverOrderBill(orderNo));
    }

    @Operation( summary= "司机发送账单",description = "司机发送账单")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @PostMapping("/sendOrderBill/{orderNo}")
    public JSONResult sendOrderBill(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.sendOrderBill(orderNo));
    }

    @Operation( summary= "加载乘客账单信息",description = "加载乘客账单信息")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @GetMapping("/customerOrderBill/{orderNo}")
    public JSONResult customerOrderBill(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.customerOrderBill(orderNo));
    }

    @Operation( summary= "保存乘客评价",description = "保存乘客评价")
    @Parameter(name = "customerCommentDto",description = "评论参数",required = true)
    @PostMapping("/saveComment")
    public JSONResult saveComment(@RequestBody  @Valid CustomerCommentDto customerCommentDto){
        return JSONResult.success(orderService.saveComment(customerCommentDto));
    }

    @Operation( summary= "加载乘客评论",description = "加载乘客评论")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @GetMapping("/loadComment/{orderNo}")
    public JSONResult loadComment(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.loadComment(orderNo));
    }

    @Operation( summary= "加载司机订单列表",description = "加载司机订单列表")
    @Parameter(name = "pagingParametersDto",description = "分页参数",required = true)
    @PostMapping("/driverLoadOrderList")
    public JSONResult driverLoadOrderList(@RequestBody  @Valid PagingParametersDto pagingParametersDto){
        return JSONResult.success(orderService.driverLoadOrderList(pagingParametersDto));
    }

    @Operation( summary= "加载司机评论",description = "加载司机评论")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @GetMapping("/driverLoadComments/{orderNo}")
    public JSONResult driverLoadComments(@PathVariable  @Valid String orderNo){
        return JSONResult.success(orderService.driverLoadComments(orderNo));
    }

    @Operation( summary= "司机申诉",description = "司机申诉")
    @Parameter(name = "driverAppealDto",description = "申诉参数",required = true)
    @PostMapping("/driverRepresentations")
    public JSONResult driverRepresentations(@RequestBody  @Valid DriverAppealDto driverAppealDto){
        return JSONResult.success(orderService.driverRepresentations(driverAppealDto));
    }
}
